define(["jquery"],function($){

    //ajax加载头部
    $("header").load("html/include/header.html",function(){
        //给输入框绑定点击事件
        $(".search>input:first").keyup(function(){
        //     var word = $(this).val();
        // var url = `https://suggest.taobao.com/sug?code=utf-8&q=${word}&callback=?`
        //     $.getJSON(url,function(data){
        //         var html ="";
        //         data.result.forEach(function(curr){
        //             html += `<div>${curr[0]}</div>`;
                   
        //         })
        //         $(".suggest").html(html);
        var word = $(this).val();    
        var url = `https://show.bilibili.com/api/ticket/search/sug?term=${word}&platform=?`
            $.getJSON(url,function(data){
                var html = "";

                data.data.result.forEach(function(curr){
                html += `<div>${curr.name}</div>`
                })
                console.log("sss");
                $(".suggest").html(html);
            })
        })

        //给suggest的孩儿绑定点击事件
        $(".suggest").delegate("div","click",function(){
            $(".search>input:first").val($(this).text());
            $(".suggest").empty();
        })
        })
    });
